﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;

namespace SPVSX.Explorer.Commands.SharePoint
{
    /// <summary>
    /// The Hide Custom Action Element
    /// </summary>
    public class HideCustomActionElement
    {
        #region Const Fields

        /// <summary>
        /// Constant to hold the group id xml attribute name
        /// </summary>
        internal const string attributeNameGroupId = "GroupId";

        /// <summary>
        /// Constant to hold the hide action id xml attribute name
        /// </summary>
        internal const string attributeNameHideActionId = "HideActionId";

        /// <summary>
        /// Constant to hold the id xml attribute name
        /// </summary>
        internal const string attributeNameId = "Id";

        /// <summary>
        /// Constant to hold the description xml attribute name
        /// </summary>
        internal const string attributeNameLocation = "Location";

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the internal <see cref="SPElementDefinition"/>
        /// </summary>
        private SPElementDefinition InternalElement { get; set; }

        /// <summary>
        /// Gets the location of this custom action.
        /// </summary>
        /// <remarks>Optional Text. If the custom action is a menu item or toolbar button, then the possible options include EditControlBlock, 
        /// NewFormToolbar, DisplayFormToolbar, and EditFormToolbar. If contained within a custom action group, the value of the Location attribute 
        /// must equal the location of the CustomActionGroup element.</remarks>
        /// <example>Microsoft.SharePoint.SiteSettings</example>
        public string Location
        {
            get { return Utility.XmlGetAttributeValue(InternalElement.XmlDefinition, attributeNameLocation); }
        }

        /// <summary>
        /// Gets the action group that contains the action. If contained within a custom action group, the value of the GroupId attribute must equal the group ID of the CustomActionGroup element.
        /// </summary>
        /// <remarks>Optional Text</remarks>
        public string GroupId
        {
            get { return Utility.XmlGetAttributeValue(InternalElement.XmlDefinition, attributeNameGroupId); }
        }

        /// <summary>
        /// Gets the unique identifier for the element. The ID may be a GUID, or it may be a unique term
        /// </summary>
        /// <remarks>Optional Text</remarks>
        /// <example>"SiteManagement". See Default Custom Action Locations and IDs for a list of the default custom action group IDs that are used in Windows SharePoint Services.</example>
        public string Id
        {
            get { return Utility.XmlGetAttributeValue(InternalElement.XmlDefinition, attributeNameId); }
        }

        /// <summary>
        /// Gets the ID of the custom action to hide.
        /// </summary>
        /// <remarks>Optional Text</remarks>
        /// <example>"HideDeleteWeb"</example>
        public string HideActionId
        {
            get { return Utility.XmlGetAttributeValue(InternalElement.XmlDefinition, attributeNameHideActionId); }
        }

        /// <summary>
        /// Gets the Element tag
        /// </summary>
        public static string RootTag
        {
            get { return "HideCustomAction"; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Create a new HideCustomActionElement object
        /// </summary>
        /// <param name="element">The <see cref="SPElementDefinition"/> object</param>
        public HideCustomActionElement(SPElementDefinition element)
        {
            InternalElement = element;
        }

        #endregion
    }
}
